home *** CD-ROM | disk | FTP | other *** search
/ PC Basics 53 / PC Basics Issue 53.iso / Software / Internet / Invboard.exe / PC Basics 53 / Invboard / upload / sources / Forums.php < prev    next >
Encoding:
PHP Script  |  2002-08-01  |  23.2 KB  |  654 lines

  1. <?php
  2.  
  3. /*
  4. +--------------------------------------------------------------------------
  5. |   IBFORUMS v1
  6. |   ========================================
  7. |   by Matthew Mecham and David Baxter
  8. |   (c) 2001,2002 IBForums
  9. |   http://www.ibforums.com
  10. |   ========================================
  11. |   Web: http://www.ibforums.com
  12. |   Email: phpboards@ibforums.com
  13. |   Licence Info: phpib-licence@ibforums.com
  14. +---------------------------------------------------------------------------
  15. |
  16. |   > Forum topic index module
  17. |   > Module written by Matt Mecham
  18. |   > Date started: 14th February 2002
  19. |
  20. |    > Module Version Number: 1.0.0
  21. +--------------------------------------------------------------------------
  22. */
  23.  
  24.  
  25. $idx = new Forums;
  26.  
  27. class Forums {
  28.  
  29.     var $output    = "";
  30.     var $base_url  = "";
  31.     var $html      = "";
  32.     var $moderator = array();
  33.     var $forum     = array();
  34.     var $show_dots = "";
  35.     var $nav_extra = "";
  36.     var $read_array = array();
  37.     
  38.     //+----------------------------------------------------------------
  39.     //
  40.     // Our constructor, load words, load skin, get DB forum/cat data
  41.     //
  42.     //+----------------------------------------------------------------
  43.     
  44.     function Forums() {
  45.         global $ibforums, $DB, $std, $print, $skin_universal;
  46.         
  47.         require "./Skin/".$ibforums->skin_id."/skin_forum.php";
  48.  
  49.         $ibforums->input['f'] = intval($ibforums->input['f']);
  50.         
  51.         $ibforums->lang      = $std->load_words($ibforums->lang, 'lang_forum', $ibforums->lang_id);
  52.  
  53.         $this->html    = new skin_forum();
  54.         
  55.         
  56.         
  57.         // Get the forum info based on the forum ID, and get the category name, ID, etc.
  58.         
  59.         $DB->query("SELECT f.*, c.id as cat_id, c.name as cat_name from ibf_forums f, ibf_categories c WHERE f.id=".$ibforums->input['f']." and c.id=f.category");
  60.         
  61.         $this->forum = $DB->fetch_row();
  62.         
  63.         //----------------------------------------
  64.         // Error out if we can not find the forum
  65.         //----------------------------------------
  66.         
  67.         if (!$this->forum['id'])
  68.         {
  69.             $std->Error( array( LEVEL => 1, MSG => 'missing_files') );
  70.         }
  71.         
  72.         //----------------------------------------
  73.         // If this is a sub forum, we need to get
  74.         // the cat details, and parent details
  75.         //----------------------------------------
  76.         
  77.         if ($this->forum['parent_id'] > 0)
  78.         {
  79.         
  80.             $DB->query("SELECT f.id as forum_id, f.name as forum_name, c.id, c.name FROM ibf_forums f, ibf_categories c WHERE f.id='".$this->forum['parent_id']."' AND c.id=f.category");
  81.             
  82.             $row = $DB->fetch_row();
  83.             
  84.             $this->forum['cat_id']   = $row['id'];
  85.             $this->forum['cat_name'] = $row['name'];
  86.         
  87.             $this->nav_extra = "<a href='".$ibforums->base_url."&act=SF&f={$row['forum_id']}'>{$row['forum_name']}</a>";
  88.         }
  89.         
  90.         //----------------------------------------
  91.         //
  92.         // If this is a sub forum, bounce back.
  93.         //
  94.         //----------------------------------------
  95.         
  96.         if ($this->forum['subwrap'] == 1)
  97.         {
  98.             $std->boink_it($ibforums->base_url."&sub=1&f=".$this->forum['id']);
  99.             exit();
  100.         }
  101.         
  102.         //--------------------------------------------------------------------------------
  103.         //--------------------------------------------------------------------------------
  104.         
  105.         $this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
  106.         
  107.         $this->forum['FORUM_JUMP'] = $std->build_forum_jump();
  108.         $this->forum['FORUM_JUMP'] = preg_replace( "!#Forum Jump#!", $ibforums->lang['forum_jump'], $this->forum['FORUM_JUMP']);
  109.         
  110.         
  111.         
  112.         // Are we viewing the forum, or viewing the forum rules?
  113.         
  114.         if ($ibforums->input['act'] == 'SR')
  115.         {
  116.             $this->show_rules();
  117.         } else {
  118.             $this->show_forum();
  119.         }
  120.         
  121.      }
  122.      
  123.     //+----------------------------------------------------------------
  124.     //
  125.     // Show the forum rules on a seperate page
  126.     //
  127.     //+----------------------------------------------------------------
  128.         
  129.     function show_rules() {
  130.         global $DB, $ibforums, $std, $print;
  131.         
  132.         //+--------------------------------------------
  133.         // Do we have permission to view these rules?
  134.         //+--------------------------------------------
  135.         
  136.         $bad_entry = $this->check_access();
  137.         
  138.         if ($bad_entry == 1)
  139.         {
  140.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_view_topic') );
  141.         }
  142.         
  143.         //+--------------------------------------------
  144.         // Get the rules from the DB
  145.         //+--------------------------------------------
  146.         
  147.         $DB->query("SELECT * FROM ibf_rules WHERE fid='".$ibforums->input['f']."'");
  148.         
  149.         if ( $rules = $DB->fetch_row() )
  150.         {
  151.             $rules['title'] = stripslashes($rules['title']);
  152.             $rules['body']  = stripslashes($rules['body']);
  153.             
  154.             $this->output .= $this->html->show_rules($rules);
  155.             
  156.             $print->add_output("$this->output");
  157.             $print->do_output( array( 'TITLE'    => "IBForums -> ".$this->forum['name'],
  158.                                       'JS'       => 0,
  159.                                       'NAV'      => array( 
  160.                                                            "<a href='".$this->base_url."&act=SC&c={$this->forum['cat_id']}'>{$this->forum['cat_name']}</a>",
  161.                                                          ),
  162.                                   ) );
  163.         }
  164.         else
  165.         {
  166.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_view_topic') );
  167.         }
  168.     }
  169.     
  170.     //+----------------------------------------------------------------
  171.     //
  172.     // Forum view check for authentication
  173.     //
  174.     //+----------------------------------------------------------------
  175.    
  176.     function show_forum() {
  177.            global $ibforums;
  178.         // are we checking for user authentication via the log in form
  179.         // for a private forum w/password protection?
  180.         
  181.         $ibforums->input['L'] == 1 ? $this->authenticate_user() : $this->render_forum();
  182.     }
  183.     
  184.     //+----------------------------------------------------------------
  185.     //
  186.     // Authenicate the log in for a password protected forum
  187.     //
  188.     //+----------------------------------------------------------------
  189.     
  190.     function authenticate_user() {
  191.         global $std, $ibforums, $print;
  192.         
  193.         if ($ibforums->input['f_password'] == "")
  194.         {
  195.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'pass_blank' ) );
  196.         }
  197.         
  198.         if ($ibforums->input['f_password'] != $this->forum['password'])
  199.         {
  200.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'wrong_pass' ) );
  201.         }
  202.         
  203.         $std->my_setcookie( "iBForum".$this->forum['id'], $ibforums->input['f_password'] );
  204.         
  205.         $print->redirect_screen( $ibforums->lang['logged_in'] , "act=SF&f=".$this->forum['id'] );
  206.         
  207.     }
  208.     
  209.     //+----------------------------------------------------------------------------------
  210.     
  211.     function check_access() {
  212.         global $ibforums, $HTTP_COOKIE_VARS;
  213.         
  214.         $return = 1;
  215.         
  216.         if ($this->forum['read_perms'] == '*')
  217.         {
  218.             $return = 0;
  219.         }
  220.         else if (preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|$)/", $this->forum['read_perms'] ) )
  221.         {
  222.             $return = 0;
  223.         }
  224.         
  225.         if ($this->forum['password'])
  226.         {
  227.             if ($HTTP_COOKIE_VARS[ $ibforums->vars['cookie_id'].'iBForum'.$this->forum['id'] ] == $this->forum['password'])
  228.             {
  229.                 $return = 0;
  230.             }
  231.             else
  232.             {
  233.                 $this->forum_login();
  234.             }
  235.         }
  236.         
  237.         return $return;
  238.     
  239.     }
  240.     
  241.     //+----------------------------------------------------------------------------------
  242.     
  243.     function forum_login() {
  244.         global $ibforums, $std, $DB, $HTTP_COOKIE_VARS, $print;
  245.         
  246.         if (empty($ibforums->member['id']))
  247.         {
  248.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_guests' ) );
  249.         }
  250.         
  251.         $this->output = $this->html->Forum_log_in( $this->forum['id'] );
  252.         
  253.         $print->add_output("$this->output");
  254.         
  255.         $print->do_output( array( 'TITLE'    => $ibforums->vars['board_name']." -> ".$this->forum['name'],
  256.                                    'JS'       => 0,
  257.                                    'NAV'      => array( 
  258.                                                           "<a href='".$this->base_url."&act=SC&c={$this->forum['cat_id']}'>{$this->forum['cat_name']}</a>",
  259.                                                           "<a href='".$this->base_url."&act=SF&f={$this->forum['id']}'>{$this->forum['name']}</a>",
  260.                                                         ),
  261.                               ) );
  262.  
  263.     }
  264.     
  265.     //+----------------------------------------------------------------
  266.     //
  267.     // Main render forum engine
  268.     //
  269.     //+----------------------------------------------------------------
  270.     
  271.     function render_forum() {
  272.         global $ibforums, $DB, $std, $print, $HTTP_COOKIE_VARS;
  273.         
  274.         $bad_entry = $this->check_access();
  275.         
  276.         if ($bad_entry == 1)
  277.         {
  278.             $std->Error( array( LEVEL => 1, MSG => 'no_permission') );
  279.         }
  280.         
  281.         if ( $read = $std->my_getcookie('topicsread') )
  282.         {
  283.             $this->read_array = unserialize(stripslashes($read));
  284.         }
  285.         
  286.         if ( $forum = $std->my_getcookie('fread_'.$ibforums->input['f']) )
  287.         {
  288.             $ibforums->input['last_visit'] = $forum > $ibforums->input['last_visit'] ? $forum : $ibforums->input['last_visit'];
  289.         }
  290.         
  291.         $prune_value = $std->select_var( array( 
  292.                                                 1 => $ibforums->input['prune_day'],
  293.                                                 2 => $this->forum['prune']        ,
  294.                                                 3 => '100'                        )
  295.                                         );
  296.  
  297.         $sort_key    = $std->select_var( array(
  298.                                                 1 => $ibforums->input['sort_key'],
  299.                                                 2 => $this->forum['sort_key']    ,
  300.                                                 3 => 'last_post'                 )
  301.                                        );
  302.  
  303.         $sort_by     = $std->select_var( array(
  304.                                                 1 => $ibforums->input['sort_by'],
  305.                                                 2 => $this->forum['sort_order'] ,
  306.                                                 3 => 'Z-A'                      )
  307.                                        );
  308.     
  309.         $First       = $std->select_var( array(
  310.                                                 1 => $ibforums->input['st'],
  311.                                                 2 => 0                    )
  312.                                        );
  313.         
  314.         // Figure out sort order, day cut off, etc
  315.         
  316.         $Prune = $prune_value != 100 ? (time() - ($prune_value * 60 * 60 * 24)) : 0;
  317.  
  318.         $sort_keys   =  array( 'last_post'         => 'sort_by_date',
  319.                                'title'             => 'sort_by_topic',
  320.                                'starter_name'      => 'sort_by_poster',
  321.                                'posts'             => 'sort_by_replies',
  322.                                'views'             => 'sort_by_views',
  323.                                'start_date'        => 'sort_by_start',
  324.                                'last_poster_name'  => 'sort_by_last_poster',
  325.                              );
  326.  
  327.         $prune_by_day = array( '1'    => 'show_today',
  328.                                '5'    => 'show_5_days',
  329.                                '7'    => 'show_7_days',
  330.                                '10'   => 'show_10_days',
  331.                                '15'   => 'show_15_days',
  332.                                '20'   => 'show_20_days',
  333.                                '25'   => 'show_25_days',
  334.                                '30'   => 'show_30_days',
  335.                                '60'   => 'show_60_days',
  336.                                '90'   => 'show_90_days',
  337.                                '100'  => 'show_all',
  338.                              );
  339.  
  340.         $sort_by_keys = array( 'Z-A'  => 'descending_order',
  341.                                 'A-Z'  => 'ascending_order',
  342.                              );
  343.                              
  344.         //+----------------------------------------------------------------                    
  345.         // check for any form funny business by wanna-be hackers
  346.         //+----------------------------------------------------------------
  347.         
  348.         if ( (!isset($sort_keys[$sort_key])) and (!isset($prune_by_day[$prune_value])) and (!isset($sort_by_keys[$sort_by])) )
  349.         {
  350.                $std->Error( array( LEVEL=> 5, MSG =>'incorrect_use') );
  351.         }
  352.         
  353.         $r_sort_by = $sort_by == 'A-Z' ? 'ASC' : 'DESC';
  354.         
  355.         //+----------------------------------------------------------------
  356.         // Query the database to see how many topics there are in the forum
  357.         //+----------------------------------------------------------------
  358.         
  359.         $DB->query("SELECT COUNT(tid) as max FROM ibf_topics WHERE forum_id='".$this->forum['id']."' and approved='1' and (last_post > $Prune or pinned=1)");
  360.         $total_possible = $DB->fetch_row();
  361.         
  362.         //+----------------------------------------------------------------
  363.         // Generate the forum page span links
  364.         //+----------------------------------------------------------------
  365.         
  366.         $this->forum['SHOW_PAGES']
  367.             = $std->build_pagelinks( array( TOTAL_POSS  => $total_possible[max],
  368.                                             PER_PAGE    => $ibforums->vars['display_max_topics'],
  369.                                             CUR_ST_VAL  => $ibforums->input['st'],
  370.                                             L_SINGLE    => $ibforums->lang['single_page_forum'],
  371.                                             L_MULTI     => $ibforums->lang['multi_page_forum'],
  372.                                             BASE_URL    => $this->base_url."&act=SF&f=".$this->forum['id']."&prune_day=$prune_value&sort_by=$sort_by&sort_order=$sort_order",
  373.                                           )
  374.                                    );
  375.                                    
  376.                                    
  377.         //+----------------------------------------------------------------
  378.         // Do we have any rules to show?
  379.         //+----------------------------------------------------------------
  380.         
  381.         if ($this->forum['show_rules'])
  382.         {
  383.             $DB->query("SELECT * from ibf_rules WHERE fid='".$this->forum['id']."'");
  384.             
  385.             if ( $rules = $DB->fetch_row() )
  386.             {
  387.                  $rules['title'] = stripslashes($rules['title']);
  388.                  $rules['body']  = stripslashes($rules['body']);
  389.                  $this->output .= $rules['show_all'] ? $this->html->show_rules_full($rules) : $this->html->show_rules_link($rules);
  390.             }
  391.         }
  392.         
  393.         //+----------------------------------------------------------------
  394.         // Generate the poll button
  395.         //+----------------------------------------------------------------
  396.            
  397.         $this->forum['POLL_BUTTON'] = $this->forum['allow_poll']
  398.                                          ? "<a href='".$this->base_url."&act=Post&CODE=10&f=".$this->forum['id']."'>{$ibforums->skin['A_POLL']}</a>"
  399.                                          : '';
  400.     
  401.         //+----------------------------------------------------------------
  402.         // Start printing the page
  403.         //+----------------------------------------------------------------
  404.         
  405.         $this->output .= $this->html->PageTop($this->forum);
  406.         
  407.         //+----------------------------------------------------------------
  408.         // Do we have any topics to show?
  409.         //+----------------------------------------------------------------
  410.         
  411.         if ($total_possible['max'] < 1)
  412.         {
  413.             $this->output .= $this->html->show_no_matches();
  414.         }
  415.         
  416.         $total_topics_printed = 0;
  417.         
  418.         if ( ($ibforums->vars['show_user_posted'] == 1) and ($ibforums->member['id']) )
  419.         {
  420.             $query = "SELECT DISTINCT ibf_posts.author_id, ibf_topics.* from ibf_topics LEFT JOIN ibf_posts ON (ibf_topics.tid = ibf_posts.topic_id AND ibf_posts.author_id = '".$ibforums->member['id']."') WHERE ibf_topics.forum_id='".$this->forum['id']."' and (ibf_topics.last_post > '$Prune' OR ibf_topics.pinned='1') and ibf_topics.approved='1'";
  421.         }
  422.         else
  423.         {
  424.             $query = "SELECT * from ibf_topics WHERE forum_id='".$this->forum['id']."' and approved='1' and (last_post > '$Prune' OR pinned='1')";
  425.         }
  426.         
  427.         //+----------------------------------------------------------------
  428.         // Do we have permission to view other posters topics?
  429.         //+----------------------------------------------------------------
  430.         
  431.         if (!$ibforums->member['g_other_topics'])
  432.         {
  433.             $query .= " and starter_id='".$ibforums->member['id']."'";
  434.         }
  435.         
  436.         //+----------------------------------------------------------------
  437.         // Finish off the query
  438.         //+----------------------------------------------------------------
  439.         
  440.         $First = $First ? $First : 0;
  441.         
  442.         $query .= " ORDER BY pinned DESC, $sort_key $r_sort_by LIMIT $First,".$ibforums->vars['display_max_topics'];
  443.         
  444.         $DB->query($query);
  445.         
  446.         //+----------------------------------------------------------------
  447.         // Grab the rest of the topics and print them
  448.         //+----------------------------------------------------------------
  449.         
  450.         while ( $topic = $DB->fetch_row() )
  451.         {
  452.             $this->output .= $this->render_entry( $topic );
  453.             $total_topics_printed++;
  454.         }
  455.         
  456.         //+----------------------------------------------------------------
  457.         // Finish off the rest of the page
  458.         //+----------------------------------------------------------------
  459.         
  460.         $ibforums->lang['showing_text'] = preg_replace( "/<#MATCHED_TOPICS#>/", $total_topics_printed  , $ibforums->lang['showing_text'] );
  461.         $ibforums->lang['showing_text'] = preg_replace( "/<#TOTAL_TOPICS#>/"  , $total_possible['max'] , $ibforums->lang['showing_text'] );
  462.         
  463.         $sort_key_html  = "<select name='sort_key'  class='forminput'>\n";
  464.         $prune_day_html = "<select name='prune_day' class='forminput'>\n";
  465.         $sort_by_html   = "<select name='sort_by'   class='forminput'>\n";
  466.         
  467.     
  468.         foreach ($sort_by_keys as $k => $v) {
  469.             $sort_by_html   .= $k == $sort_by     ? "<option value='$k' selected>" . $ibforums->lang[ $sort_by_keys[ $k ] ] . "\n"
  470.                                                   : "<option value='$k'>"          . $ibforums->lang[ $sort_by_keys[ $k ] ] . "\n";
  471.         }
  472.     
  473.         foreach ($sort_keys as  $k => $v) {
  474.             $sort_key_html  .= $k == $sort_key    ? "<option value='$k' selected>" . $ibforums->lang[ $sort_keys[ $k ] ]    . "\n"
  475.                                                   : "<option value='$k'>"          . $ibforums->lang[ $sort_keys[ $k ] ]    . "\n";
  476.         }
  477.         foreach ($prune_by_day as  $k => $v) {
  478.             $prune_day_html .= $k == $prune_value ? "<option value='$k' selected>" . $ibforums->lang[ $prune_by_day[ $k ] ] . "\n"
  479.                                                   : "<option value='$k'>"          . $ibforums->lang[ $prune_by_day[ $k ] ] . "\n";
  480.         }
  481.     
  482.         $ibforums->lang['sort_text'] = preg_replace( "!<#SORT_KEY_HTML#>!", "$sort_key_html</select>"  , $ibforums->lang['sort_text'] );
  483.         $ibforums->lang['sort_text'] = preg_replace( "!<#ORDER_HTML#>!"   , "$sort_by_html</select>"   , $ibforums->lang['sort_text'] );
  484.         $ibforums->lang['sort_text'] = preg_replace( "!<#PRUNE_HTML#>!"   , "$prune_day_html</select>" , $ibforums->lang['sort_text'] );
  485.     
  486.         $this->output .= $this->html->TableEnd($this->forum);
  487.         
  488.         //+----------------------------------------------------------------
  489.         // Are we a moderator?
  490.         //+----------------------------------------------------------------
  491.         
  492.         if ( ($ibforums->member['id']) and ($ibforums->member['g_is_supmod'] != 1) )
  493.         {
  494.             $DB->query("SELECT mid FROM ibf_moderators WHERE forum_id='".$this->forum['id']."' and member_id='".$ibforums->member['id']."'");
  495.             $this->moderator = $DB->fetch_row();
  496.         }
  497.         
  498.         //+----------------------------------------------------------------
  499.         // Do we have to print the moderators CP link?
  500.         //+----------------------------------------------------------------
  501.         
  502.         if ($ibforums->member['g_is_supmod'] or $this->moderator['mid'])
  503.         {
  504.             $this->output .= $this->html->Mod_Panel( $this->forum['id'] );
  505.         }
  506.     
  507.         //+----------------------------------------------------------------
  508.         // Print it
  509.         //+----------------------------------------------------------------
  510.         
  511.         $print->add_output("$this->output");
  512.         $print->do_output( array( 'TITLE'    => $ibforums->vars['board_name']." -> ".$this->forum['name'],
  513.                                    'JS'       => 0,
  514.                                    'NAV'      => array( 
  515.                                                           "<a href='".$this->base_url."&act=SC&c={$this->forum['cat_id']}'>{$this->forum['cat_name']}</a>",
  516.                                                           $this->nav_extra,
  517.                                                           "<a href='".$this->base_url."&act=SF&f={$this->forum['id']}'>{$this->forum['name']}</a>",
  518.                                                         ),
  519.                               ) );
  520.  
  521.         
  522.  
  523.     }
  524.      
  525.     //+----------------------------------------------------------------
  526.     //
  527.     // Crunches the data into pwetty html
  528.     //
  529.     //+----------------------------------------------------------------
  530.  
  531.     function render_entry($topic) {
  532.         global $DB, $std, $ibforums;
  533.         
  534.         $topic['last_text']   = $ibforums->lang['last_post_by'];
  535.         
  536.         $topic['last_poster'] = ($topic['last_poster_id'] != 0)
  537.                                 ? "<b><a href='{$this->base_url}&act=Profile&CODE=03&MID={$topic['last_poster_id']}'>{$topic['last_poster_name']}</a></b>"
  538.                                 : "-".$topic['last_poster_name']."-";
  539.                                 
  540.         $topic['starter']     = ($topic['starter_id']     != 0)
  541.                                 ? "<a href='{$this->base_url}&act=Profile&CODE=03&MID={$topic['starter_id']}'>{$topic['starter_name']}</a>"
  542.                                 : "-".$topic['starter_name']."-";
  543.      
  544.         if ($topic['poll_state'])
  545.         {
  546.             $topic['prefix']     = $ibforums->vars['pre_polls'].' ';
  547.         }
  548.         
  549.         if ( ($ibforums->member['id']) and ($topic['author_id']) )
  550.         {
  551.             $show_dots = 1;
  552.         }
  553.     
  554.         $topic['folder_img']     = $std->folder_icon($topic, $show_dots, $this->read_array[$topic['tid']]);
  555.         
  556.         $topic['topic_icon']     = $topic['icon_id']  ? '<img src="'.$ibforums->vars['img_url'] . '/icon' . $topic['icon_id'] . '.gif" border="0" alt="">'
  557.                                                       : ' ';
  558.         
  559.         $topic['start_date'] = $std->get_date( $topic['start_date'], 'LONG' );
  560.     
  561.     
  562.         $pages = 1;
  563.         
  564.         if ($topic['posts'])
  565.         {
  566.             if ( (($topic['posts'] + 1) % $ibforums->vars['display_max_posts']) == 0 )
  567.             {
  568.                 $pages = ($topic['posts'] + 1) / $ibforums->vars['display_max_posts'];
  569.             }
  570.             else
  571.             {
  572.                 $number = ( ($topic['posts'] + 1) / $ibforums->vars['display_max_posts'] );
  573.                 $pages = ceil( $number);
  574.             }
  575.             
  576.         }
  577.         
  578.         if ($pages > 1) {
  579.             $topic['PAGES'] = "<span id='small'>({$ibforums->lang['topic_sp_pages']} ";
  580.             for ($i = 0 ; $i < $pages ; ++$i ) {
  581.                 $real_no = $i * $ibforums->vars['display_max_posts'];
  582.                 $page_no = $i + 1;
  583.                 if ($page_no == 4) {
  584.                     $topic['PAGES'] .= "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&st=" . ($pages - 1) * $ibforums->vars['display_max_posts'] . "'>...$pages </a>";
  585.                     break;
  586.                 } else {
  587.                     $topic['PAGES'] .= "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&st=$real_no'>$page_no </a>";
  588.                 }
  589.             }
  590.             $topic['PAGES'] .= ")</span>";
  591.         }
  592.         
  593.         if ($topic['posts'] < 0) $topic['posts'] = 0;
  594.         
  595.         $last_time = $this->read_array[ $topic['tid'] ] > $ibforums->input['last_visit'] ? $this->read_array[ $topic['tid'] ] : $ibforums->input['last_visit'];
  596.         
  597.         if ($last_time  && ($topic['last_post'] > $last_time))
  598.         {
  599.             $topic['go_last_page'] = "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&view=getlastpost'>" . $ibforums->skin['GO_LAST_ON'] . "</a>";
  600.             $topic['go_new_post']  = "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&view=getnewpost'>"  . $ibforums->skin['NEW_POST']   . "</a>";
  601.         
  602.         }
  603.         else
  604.         {
  605.             $topic['go_last_page'] = "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&view=getlastpost'>" . $ibforums->skin['GO_LAST_OFF'] . "</a>";
  606.             $topic['go_new_post']  = "";
  607.         }
  608.         
  609.     
  610.         $topic['last_post']  = $std->get_date( $topic['last_post'], 'SHORT' );
  611.         
  612.         //+----------------------------------------------------------------
  613.             
  614.         if ($topic['state'] == 'link')
  615.         {
  616.             $t_array = explode("&", $topic['moved_to']);
  617.             $topic['tid']       = $t_array[0];
  618.             $topic['forum_id']  = $t_array[1];
  619.             $topic['title']     = $topic['title'];
  620.             $topic['views']     = '--';
  621.             $topic['posts']     = '--';
  622.             $topic['prefix']    = $ibforums->vars['pre_moved']." ";
  623.             $topic['go_new_post'] = "";
  624.         }
  625.         
  626.         if ($topic['pinned'] == 1)
  627.         {
  628.             $topic['prefix']     = $ibforums->vars['pre_pinned'];
  629.             $topic['topic_icon'] = $ibforums->skin['B_PIN'];
  630.             
  631.         }
  632.         
  633.         return $this->html->RenderRow( $topic );
  634.     }
  635.     
  636.     
  637.     //+----------------------------------------------------------------
  638.     //
  639.     // Returns the last action date
  640.     //
  641.     //+----------------------------------------------------------------
  642.         
  643.     function get_last_date($topic) {
  644.         global $ibforums, $std;
  645.         
  646.         return $std->get_date( $topic['last_post'], 'SHORT' );
  647.         
  648.     }
  649.  
  650.         
  651. }
  652.  
  653. ?>
  654.